<template>
  <el-table
      :data="data"
      :span-method="objectSpanMethod"
      border
      style="width: 100%; ">
      <el-table-column
        prop="reviewItemOne"
        label="评审项目"
            align="center"
        width="100">
      </el-table-column>
      <el-table-column
        prop="reviewContent"
        align="left"
        label="评审内容及要求">
          <template slot-scope="scope">
              <div  v-if='scope.row.flag==0' >
                  <img v-for='(item,index) in scope.row.reviewContent' 
                style="width:120px;height:60px;padding:10px;float:left;" 
                :src="item" :key='index' alt="">
              </div>
           
            <p v-else style="text-align:left;">{{scope.row.reviewContent}}</p>
          </template>
      </el-table-column>
      <el-table-column
        label="评审意见"
         align="center"
        >
          <el-table-column label="符合" width="80" prop="reviewMethod" align="center">
              <template slot-scope="scope">
                  <template v-if="!falg1">
                    <img v-if='!flag' :src="scope.row.result==1?'../../../static/images/r1.png':'../../../static/images/r2.png'" class="radioImg">
                    <img  v-else @click='scope.row.result="1"' :src="scope.row.result==1?'../../../static/images/r1.png':'../../../static/images/r2.png'" class="radioImg">
                  </template>
                   <template v-else>
                       {{scope.row.result==1?'√':''}}
                    </template>
              </template>
          </el-table-column>
          <el-table-column label="基本符合" width="80" prop="reviewMethod"  align="center">
              <template slot-scope="scope">
                  <template v-if="!falg1">
                    <img v-if='!flag'  :src="scope.row.result==2?'../../../static/images/r1.png':'../../../static/images/r2.png'"  class="radioImg">
                    <img  v-else  @click='scope.row.result="2"' :src="scope.row.result==2?'../../../static/images/r1.png':'../../../static/images/r2.png'"  class="radioImg">
                  </template>
                  <template v-else>
                       {{scope.row.result==2?'√':''}}
                  </template>
             </template>
          </el-table-column>
          <el-table-column label="不符合" width="80" prop="reviewMethod"  align="center">
              <template slot-scope="scope">
                  <template v-if="!falg1">
                    <img v-if='!flag'   :src="scope.row.result==3?'../../../static/images/r1.png':'../../../static/images/r2.png'"  class="radioImg">
                    <img  v-else  @click='scope.row.result="3"' :src="scope.row.result==3?'../../../static/images/r1.png':'../../../static/images/r2.png'"  class="radioImg">
                  </template>
                  <template v-else>
                       {{scope.row.result==3?'√':''}}
                  </template>
              </template>
          </el-table-column>
      </el-table-column>
    </el-table>
</template>
<script>
export default {
  props:['data'],
  data(){
    return {
      flag:true,
      falg1:false
    }
  },
  methods:{
    countTimes(data) {
        var obj = {};
        return data.reduce(function(time, name) {

            if (name.reviewItemOne in time) {
                time[name.reviewItemOne]++;
            } else {
                time[name.reviewItemOne] = 1;
            }
            return time;
        }, {});
    },
   objectSpanMethod({ row, column, rowIndex, columnIndex }) {
       var obj =this.countTimes(this.data)
       var arr = [],arr2=[],obj2=[],k=0
       for(var i in obj){
          arr.push(obj[i])
       }
         arr.map((item,index)=>{
            obj2.push({val:item,idx:k});
            k+=item
        })
        this.data.map(function(item,index){
          arr2.push(0)
           obj2.map(item=>{
              if(item.idx == index){
                arr2[item.idx]=item.val
              }
           })
          
        })
    if (columnIndex === 0) {
          if (rowIndex  == 0) {
            return {
              rowspan: arr2[rowIndex],
              colspan: 1
            };

          } else{
             return {
              rowspan: arr2[rowIndex],
              colspan: arr2[rowIndex] == 0 ? 0 : 1
            };
          }
        }
         if (rowIndex  === 6) {
          if (columnIndex === 1) {
            return [2, 4];
          } 
        }
       
      }
  },
  mounted(){
    console.log(this.data)
    var str = window.location.href
    if(str.indexOf('assessedAll2')!=-1  || str.indexOf('checkAssessed2')!=-1 ){
      this.flag=false
    }else{
      this.flag=true
      if(str.indexOf('onlineAssess2') !=-1){
          this.falg1 = true
      }else{
          this.falg1 = false
      }
    }
  }
}
</script>
<style lang="less">

</style>
<style lang="">
  .radioImg{
    width:25px;
    height:25px;
  }
  .el-table thead.is-group th{
          color: rgb(51, 51, 51);
    font-weight: bold;
    }
</style>


